// src/components/6BuildInComp/3KeepAliveCache/cacheManager.js
import { ref } from 'vue'

const cacheManager = {
  cache: ref({}),

  add(key, component) {
    this.cache.value[key] = component
  },

  remove(key) {
    delete this.cache.value[key]
  },

  getCache() {
    return this.cache.value
  },

  destroy(key) {
    if (this.cache.value[key]) {
      delete this.cache.value[key]
      console.log(`Destroyed component: ${key}`)
    }
  }
}

export default cacheManager